NetworkApi

interface NetworkApi

API for multiloader abstraction of simple play-phase networking

Author

fzzyhmstrs

Since

0.4.1

Functions

Link copied to clipboard
abstract fun buf(): PacketByteBuf

Shorthand for creating a PacketByteBuf

Link copied to clipboard
abstract fun canSend(id: Identifier, playerEntity: PlayerEntity?): Boolean

Checks whether a certain channel can be used for sending a packet. Works in both networking directions.

Link copied to clipboard
abstract fun <T : CustomPayload> registerC2S(id: Identifier, function: Function<PacketByteBuf, T>, handler: C2SPayloadHandler<T>)

registers a serverbound (C2S) payload type and receipt handler. This must be done on both logical sides (client and server). A common entrypoint is typically the best place for this.

Link copied to clipboard
abstract fun <T : CustomPayload> registerS2C(id: Identifier, function: Function<PacketByteBuf, T>, handler: S2CPayloadHandler<T>)

registers a clientbound (S2C) payload type and receipt handler. This must be done on both logical sides (client and server). A common entrypoint is typically the best place for this.

Link copied to clipboard
abstract fun send(payload: CustomPayload, playerEntity: PlayerEntity?)

Sends a payload to a receiver. If the server player is defined, will be an S2C transmission, otherwise C2S